//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类.demo20AND40;

public class demo35 {
    public demo35() {
    }

    public int searchInsert(int[] nums, int target) {
        int left = 0;
        int right = nums.length - 1;
        int min = 0;

        while(left <= right) {
            min = (int)((long)(right + left) / 2L);
            if (nums[min] < target) {
                left = min + 1;
            } else {
                if (nums[min] <= target) {
                    return min;
                }

                right = min - 1;
            }
        }

        if (target > nums[min]) {
            return min + 1;
        } else {
            return min;
        }
    }
}
